home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1996 August / WPCAUG96.ISO / makers / search.dir / 00075_Bsearch script.ls < prev    next >
Encoding:
Text File  |  1996-06-12  |  677 b   |  28 lines

  1. on Bsearch str, txt
  2.   set txt to the number of cast txt
  3.   set start to 1
  4.   set end to the number of lines in field txt
  5.   set middle to (start + end) / 2
  6.   set str to value(str)
  7.   put str
  8.   repeat while str <> value(item 1 of line middle of field txt)
  9.     if str = value(item 1 of line end of field txt) then
  10.       return end
  11.     end if
  12.     if start = middle then
  13.       return 0
  14.     end if
  15.     if str < value(item 1 of line middle of field txt) then
  16.       set end to middle
  17.     else
  18.       set start to middle
  19.     end if
  20.     set middle to (start + end) / 2
  21.   end repeat
  22.   if str = value(item 1 of line middle of field txt) then
  23.     return middle
  24.   else
  25.     return 0
  26.   end if
  27. end
  28.